<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<!doctype html>
<html class="no-js">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>上传管理</title>
<meta name="description" content="拉勾数据">
<meta name="keywords" content="二手房 房产经济 房企 开发商 拉勾数据 IFS">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="renderer" content="webkit">
<meta http-equiv="Cache-Control" content="no-siteapp" />
<link rel="icon" type="image/png" href="assets/i/favicon.png">
<link rel="apple-touch-icon-precomposed"
	href="assets/i/app-icon72x72@2x.png">
<meta name="apple-mobile-web-app-title" content="eosms for IFS" />
<link rel="stylesheet" href="assets/css/amazeui.min.css" />
<link rel="stylesheet" href="assets/css/admin.css">
</head>
<body>
	<!--[if lte IE 9]>
<p class="browsehappy">你正在使用<strong>过时</strong>的浏览器，Amaze UI 暂不支持。 请 <a href="http://browsehappy.com/" target="_blank">升级浏览器</a>
  以获得更好的体验！</p>
<![endif]-->
	<jsp:include page="/manage_header.do" flush="true" />

	<div class="am-cf admin-main">
		<!-- sidebar start -->
		<jsp:include page="/manage_tree.do" flush="true"><jsp:param
				name="user_id" value="${user.id}" /></jsp:include>
		<!-- sidebar end -->

		<!-- content start -->
		<div class="admin-content">

			<div class="am-cf am-padding">
				<div class="am-fl am-cf">
					<strong class="am-text-primary am-text-lg">上传</strong> / <small>apkload</small>
				</div>
			</div>
			<form id="apkload_form" class="am-form am-form-horizontal"
				enctype="multipare/form-data" action="show_add_apkload.do">
				<input type="hidden" name="id" id="id" value="0"> <input
					type="hidden" name="page_num" id="page_num" value="0">
				<div class="am-tabs am-margin" data-am-tabs>
					<ul class="am-tabs-nav am-nav am-nav-tabs">
						<li class="am-active"><a href="#tab1">上传</a></li>
					</ul>


					<div class="am-tabs-bd">
						<div class="am-tab-panel am-fade am-in am-active" id="tab1">
							<div class="am-g am-margin-top">
								<div class="am-form-group">
									<label for="user-name" class="am-u-sm-3 am-form-label">版本号</label>
									<div class="am-u-sm-9 am-u-md-9">
										<input type="text" class="am-input-sm" name="versionNumber"
											id="versionNumber" value="">
									</div>
								</div>

								<div class="am-form-group">
									<label for="user-name" class="am-u-sm-3 am-form-label">上传apk</label>
									<div class="am-u-sm-6 am-u-lg-6 am-text-left">
										<input type="text" name="apkurl" id="apkurl" readonly="true"
											style="height: 30px">
									</div>

									<div class="am-u-sm-3 am-u-lg-3 am-text-left">
										<input type='button' value='浏览' OnClick="file.click();"
											class="am-btn am-btn-primary am-btn-xs" /> <input
											type="file" name="file" id="file"
											onChange="geturl(this.value)"> <br>
									</div>
								</div>
							</div>
						</div>
						<div class="am-g am-margin-top">
							<div class="am-margin am-text-center">
								<button type="button" id="button"
									class="am-btn am-btn-primary am-btn-xs">提交</button>
							</div>
						</div>
					</div>
				</div>
			</form>
			<!-- //////////////////////////////////////////// -->
			<div class="am-g">
				<div class="am-u-sm-12">
					<form class="am-form">
						<table id="clients_table"
							class="am-table am-table-striped am-table-hover table-main">
							<thead>
								<tr>
									<th class="table-title" width="10%">版本号</th>
									<th class="table-title" width="25%">创建时间</th>
									<th class="table-title" width="55%">上传路径</th>
									<th class="table-title" width="10%">状态</th>

								</tr>
							</thead>
							<tbody>

									<c:forEach var="apk" items="${apks}" varStatus="s">
									<tr class="tr_click" apk_id="${apk.id}">
										<td>${apk.versionNumber}</td>
										<td>${apk.create_time}</td>
										<td>${apk.filepath}</td>
										<td class="td1">
										    <c:choose>
												<c:when test="${apk.status==1}">  
         											  可用     
   												</c:when>
												<c:otherwise> 
													   禁用 
  											    </c:otherwise>
										     </c:choose>
										</td>
									</tr>
								</c:forEach> 
							</tbody>
						</table>
						<div class="am-cf">
							共 ${page.allRow} 条记录
							<div class="am-fr">
								<ul class="am-pagination">
									<c:choose>
										<c:when test="${page.currentPage==1}">
											<li class="am-disabled"><a href="#">«</a></li>
										</c:when>
										<c:when test="${page.currentPage!=1}">
											<li><a href="javascript:void(0)"
												onclick="choose_page(${page.currentPage-1})">«</a></li>
										</c:when>
									</c:choose>
									<c:forEach var="i" begin="1" end="${page.totalPage}" step="1">
										<c:choose>
											<c:when test="${page.currentPage==i}">
												<li class="am-active"><a href="javascript:void(0)"><c:out
															value="${i}" /></a></li>
											</c:when>
											<c:when test="${page.currentPage!=i}">
												<li><a href="javascript:void(0)"
													onclick="choose_page(${i})"><c:out value="${i}" /></a></li>
											</c:when>
										</c:choose>
									</c:forEach>
									<c:choose>
										<c:when test="${page.currentPage==page.totalPage}">
											<li class="am-disabled"><a href="#">»</a></li>
										</c:when>
										<c:when test="${page.currentPage!=page.totalPage}">
											<li><a href="javascript:void(0)"
												onclick="choose_page(${page.currentPage+1})">»</a></li>
										</c:when>
									</c:choose>
								</ul>
							</div>
						</div>
					</form>
				</div>
			</div>
			<!-- //////////////////////////////////////////// -->
		</div>
	</div>

	<!-- content end -->

	<a href="#" class="am-show-sm-only admin-menu"
		data-am-offcanvas="{target: '#admin-offcanvas'}"> <span
		class="am-icon-btn am-icon-th-list"></span>
	</a>

	<jsp:include page="/manage_foot.do" flush="true" />

	<!--[if lt IE 9]>
<script src="http://libs.baidu.com/jquery/1.11.1/jquery.min.js"></script>
<script src="http://cdn.staticfile.org/modernizr/2.8.3/modernizr.js"></script>
<script src="assets/js/amazeui.ie8polyfill.min.js"></script>
<![endif]-->

	<!--[if (gte IE 9)|!(IE)]><!-->
	<script src="assets/js/jquery.min.js"></script>
	<!--<![endif]-->
	<script src="assets/js/amazeui.min.js"></script>
	<script src="assets/js/app.js"></script>
	<script type="text/javascript">
 function geturl(url){
    	$("#apkurl").val(url);
    	 //$("#imgdiv").show();
    	 var r= new FileReader();
		   f=document.getElementById('file').files[0];
		   r.readAsDataURL(f);		  
    }
$(function() {
	//页面初始化时默认新增机构，所以隐藏新增按钮
	  $("#file").hide();
	  $("#file").hide();
	//保存按钮点击事件
	$("#button").click(function() {
		var formData = new FormData($( "#apkload_form" )[0]); 
	     //		var saveData={"id":$("#id").val(),"title":$("#title").val()};
			$.ajax({
				//contentType:"application/json",
			    type : "POST",
			    url : "<%=request.getContextPath()%>/get_commitApk.do?id="+ $("#id").val() + "",
				data : formData,
				async : false,
				cache : false,
				contentType : false,
				processData : false,
				//    dataType: "json",

				success : function(data) {
					if (data.flag == "1") {
						$("#id").val(data.id);
						$('#apkload_form')[0]
								.reset();
						$("#apkload_form").submit();
						alert("保存成功！");
					} else {
						alert("保存失败！");
					}
				},
				error : function() {
					alert("网络连接出错！");
				}
			});

		});

		});

		function choose_page(i) {
			$("#page_num").val(i);
			$("#apkload_form").submit();
		}
	</script>
</body>
</html>

